package com.usian.controller;

import com.usian.pojo.User;
import com.usian.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@Controller
@RequestMapping("user")
public class UserController {
    @Autowired
    private UserService userService;



    @RequestMapping("in")
    public String in(){
        return "login";
    }


    @RequestMapping("/login1")
    public String login(String name,String password){

        List<User> list = userService.findById();
        for (User user : list) {
            if (!name.equals(user.getName()) && !password.equals(user.getPassword())){
                return "login";
            }else {
                if (user.getFlag()==0){
                    return "redirect:/commodity/findAll";
                }else {
                    return "redirect:/commodity/findAll";
                }
            }
        }
        return "login";
    }
}
